package com.qf.lja.servlet;

import com.qf.lja.dao.ProductDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet(urlPatterns = "/updateInventory")
public class UpdatePro extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //utf-8
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        String price = req.getParameter("price");
        String inventory = req.getParameter("inventory");
        String p_id = req.getParameter("p_id");

        System.out.println("p : " + price);

        ProductDao productDao = new ProductDao();
        productDao.updatemp(price, inventory, p_id);

        resp.sendRedirect("productAdmin");
    }
}
